% create (EEGLAB) STUDY using all subjects
% ----------------------------------------
subjectNames = { 'c1'  'c2'  'c3'  'c4'  'c5'  'c6'  'c7'  'c8' ...
                 'nd1' 'nd2' 'nd3' 'nd4' 'nd5' 'nd6' 'nd7' 'nd8' };

eeglab;
commands = {};
for index = 1:length(subjectNames);
    filename = fullfile(subjectNames{index}, [ subjectNames{index} '_med.set' ]);
    commands{end+1} = { 'index' index 'load' filename };
end;
STUDY = [];
ALLEEG = [];
[STUDY ALLEEG] = std_editset( STUDY, ALLEEG,  'commands', commands);
EEG = ALLEEG;
CURRENTSTUDY = 1;
CURRENTSET = [1:length(ALLEEG)];
eeglab redraw

save -mat nondual16subjects_med.study STUDY
